package wqh.pojo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by devts on 2016/9/25.
 */
public class MapRet {

    public static Map<String, Object> ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "执行错误。");
        return map;
    }

    public static Map<String, Object> ERROR(String err)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", err);
        return map;
    }

    public static Map<String, Object> EXIST()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "数据已存在。");
        return map;
    }

    public static Map<String, Object> EMPTY(String string)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "系统中 [" + string + "] 不存在。");
        return map;
    }

    public static Map<String, Object> SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "执行成功。");
        return map;
    }

    public static Map<String, Object> SQL_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "SQL执行错误。");
        return map;
    }

    public static Map<String, Object> SQL_ERROR(String error)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", error);
        return map;
    }

    public static Map<String, Object> SQL_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "SQL执行成功。");
        return map;
    }

    public static Map<String, Object> DATA(Object o)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        if(o == null){
            map.put("data",new ArrayList<Object>());
            return map;
        }
        map.put("data", o);
        return map;
    }

    public static Map<String, Object> DATA_OBJECT(Object o)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        List<Object> objectList = new ArrayList<Object>();
        objectList.add(o);
        map.put("code", 0);
        map.put("data", objectList);
        return map;
    }

    public static Map<String, Object> DATA_ERROR(Object o)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -2);
        map.put("data", o);
        return map;
    }

    public static Map<String, Object> DATA2(int count,Object o)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("number",count);
        map.put("data", o);
        return map;
    }

    public static Map<String, Object> SQL_UPDATE_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "SQL更新错误。");
        return map;
    }

    public static Map<String, Object> SQL_UPDATE_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "SQL更新成功。");
        return map;
    }

    public static Map<String, Object> SQL_DELETE_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "数据删除成功。");
        return map;
    }

    public static Map<String, Object> SQL_DELETE_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "数据删除失败。");
        return map;
    }

    public static Map<String, Object> SQL_INSERT_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "数据新添成功。");
        return map;
    }

    public static Map<String, Object> SQL_INSERT_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "数据新添失败。");
        return map;
    }

    public static Map<String, Object> SQL_SELECT_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "数据查询失败。");
        return map;
    }

    public static Map<String, Object> IP_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "IP地址格式错误。");
        return map;
    }

    public static Map<String, Object> FILE_UPLOAD_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -2);
        map.put("error", "文件上传错误。");
        return map;
    }

    public static Map<String, Object> FILE_UPLOAD_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "文件上传成功。");
        return map;
    }

    public static Map<String, Object> FILE_DOWNLOAD_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -2);
        map.put("error", "文件下载错误。");
        return map;
    }

    public static Map<String, Object> FILE_DOWNLOAD_SUCCESS()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("success", "文件下载成功。");
        return map;
    }

    public static Map<String, Object> SQL_SELECT_NONE()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "数据查询为空。");
        return map;
    }

    public static Map<String, Object> VALUE_ERROR(String val)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -1);
        map.put("error", "参数： " + val + " 错误。");
        return map;
    }

    public static Map<String, Object> PAGE_DATA(Object object, int pageNum,int pageSize, long total, int pages)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("data",object);
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        map.put("total",total);
        map.put("pages",pages);
        return map;
    }

    public static Map<String, Object> EXCEL_ERROR()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", -2);
        map.put("error", "xls格式错误。");
        return map;
    }

    public static Map<String, Object> DATATABLES(int draw,int recordsTotal,int recordsFiltered,Object data)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("draw",draw);
        map.put("recordsTotal",recordsTotal);
        map.put("recordsFiltered",recordsFiltered);
        map.put("data",data);
        return map;
    }

}
